]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
panelMenu: Close menu when hiding the corresponding button
authorFlorian Müllner <fmuellner@gnome.org>
Wed, 3 Jul 2013 13:55:35 +0000 (15:55 +0200)
committerFlorian Müllner <fmuellner@gnome.org>
Thu, 11 Jul 2013 15:14:02 +0000 (17:14 +0200)
A PanelMenuButton added to the top bar might not be visible at all
times. If it is hidden while the corresponding menu is open, we
currently don't do anything at all, e.g. the menu remains open
pointing to an arbitrary location in the top bar.
Instead, close the menu automatically in that case.

https://bugzilla.gnome.org/show_bug.cgi?id=703540

js/ui/panelMenu.js

index b73152eb014b0c0c13e27c01198d287fa987f193..d77143b1704cd5d608214a7345355b79c18e3d54 100644 (file)
@@ -110,6 +110,7 @@ const Button = new Lang.Class({
 
         this.actor.connect('button-press-event', Lang.bind(this, this._onButtonPress));
         this.actor.connect('key-press-event', Lang.bind(this, this._onSourceKeyPress));
+        this.actor.connect('notify::visible', Lang.bind(this, this._onVisibilityChanged));
 
         if (dontCreateMenu)
             this.menu = new PopupMenu.PopupDummyMenu(this.actor);
@@ -183,6 +184,14 @@ const Button = new Lang.Class({
             return false;
     },
 
+    _onVisibilityChanged: function() {
+        if (!this.menu)
+            return;
+
+        if (!this.actor.visible)
+            this.menu.close();
+    },
+
     _onMenuKeyPress: function(actor, event) {
         if (global.focus_manager.navigate_from_event(event))
             return true;